package cn.funeralobjects.upms.entity;

import cn.funeralobjects.common.annotations.*;
import cn.funeralobjects.common.jpa.entity.BaseDelSaltJpaEntity;
import cn.funeralobjects.upms.converter.UserCertificateTypeConverter;
import cn.funeralobjects.upms.enums.UserCertificateType;
import cn.funeralobjects.util.converter.DefaultBooleanShortConverter;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;

import javax.persistence.*;
import java.util.Date;

/**
 * 用户凭证信息
 *
 * @author FuneralObjects
 * Create date: 2020/6/3 2:34 PM
 */
@EqualsAndHashCode(callSuper = true)
@Data
@Accessors(chain = true)
@DynamicInsert
@DynamicUpdate
@Table(name = "t_user_certificate")
@Entity
public class EUserCertificate extends BaseDelSaltJpaEntity<Integer> {

    /**
     * 所属用户
     */
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "user_id", updatable = false)
    private EUser user;
    /**
     * 凭证值
     */
    private String cert;
    /**
     * 凭证类型
     */
    @Convert(converter = UserCertificateTypeConverter.class)
    private UserCertificateType type;
    /**
     * 编码
     */
    @Code
    private String code;
    /**
     * 是否启用禁用
     */
    @Convert(converter = DefaultBooleanShortConverter.class)
    @Enable
    private Boolean enable;
    /**
     * 是否已经提交
     */
    @Convert(converter = DefaultBooleanShortConverter.class)
    @Commit
    private Boolean commit;
    /**
     * 创建日期
     */
    @Temporal(TemporalType.TIMESTAMP)
    @CreateTime
    private Date createTime;
    /**
     * 更新日期
     */
    @Temporal(TemporalType.TIMESTAMP)
    @UpdateTime
    private Date updateTime;
}
